package com.dykj.fireFighting.web.controller;

import com.dykj.fireFighting.api.base.enterprise.service.IEnterpriseService;
import com.dykj.fireFighting.api.socialUnit.buildmanger.service.IBuildingService;
import com.dykj.fireFighting.api.socialUnit.buildmanger.service.IPartitionsService;
import com.dykj.fireFighting.api.socialUnit.devicemanger.entity.PartitionsDevice;
import com.dykj.fireFighting.api.socialUnit.devicemanger.service.IPartitionsDeviceService;
import com.dykj.fireFighting.common.core.annotation.AutoLog;
import com.dykj.fireFighting.common.core.api.CommonResult;
import com.dykj.fireFighting.common.core.vo.LoginUserVo;
import com.dykj.fireFighting.common.core.vo.TreeVo;
import com.dykj.fireFighting.web.base.shiro.ShiroUtil;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author fgc
 * @Date 2021/8/27 15:23
 * @ Description：监控中心查询建筑分区
 */
@RestController
@RequestMapping("buildmanger/")
public class BuildingController {
    @DubboReference
    private IBuildingService buildingService;
    @DubboReference
    private IPartitionsDeviceService partitionsDeviceService;
    @DubboReference
    private IEnterpriseService enterpriseService;


    /**
     * 部门 -- 楼栋 --  楼层  -- 分区
     *
     * @return
     */
    @AutoLog(value = "部门--楼栋--楼层--分区")
    @ApiOperation(value = "部门--楼栋--楼层--分区", notes = "部门--楼栋--楼层--分区")
    @GetMapping("/building/queryBuildFloorPartitionsTree")
    public CommonResult<TreeVo> queryBuildFloorPartitionsTree(@RequestParam("unitId") String unitId) {

        List<TreeVo> treeVoList = new ArrayList<>();

        TreeVo treeVo = new TreeVo();
        treeVo.setId(enterpriseService.getById(unitId).getId().toString());
        treeVo.setLabel(enterpriseService.getById(unitId).getEnterpriseName());
        treeVo.set_level(0);

        List<TreeVo> buildingList = buildingService.queryBuildFloorPartitionsTree(unitId);
        treeVo.setChildren(buildingList);
        return CommonResult.success(treeVo);
    }
    @GetMapping("/partitions/getPartitionsDeviceAndVideo")
    @AutoLog(value = "大数据页面查询设备")
    public CommonResult getPartitionsDevice(@RequestParam("partitionId") String partitionId){
        List<PartitionsDevice> list=partitionsDeviceService.getList(partitionId);
        return CommonResult.success(list);
    }
}
